<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
 Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="workspaceManager.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>workspaceManager.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		No overview generated for 'workspaceManager.js'<BR/><BR/>
	
</p>

<hr>


    <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr bgcolor="#CCCCFF" class="TableHeadingColor">
    <td colspan=2><font size="+2">
    
        <b>Class Summary</b>
    
    </font></td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="workspaceManager.html">workspaceManager</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    </table>
    <hr/> 


<!-- ========== METHOD SUMMARY =========== -->

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">/**
 * A workspace manager may create and remove workspaces.
 * It's also possible to recover or load a workspace previously saved.
 * It's role is to manage the existing workspaces.
 * <span class="attrib">@author</span> Roosevelt de Lima Sardinha
 * <span class="attrib">@constructor</span>
 */</span>
<span class="reserved">function</span> workspaceManager(){
	
	<span class="comment">/**
	 * Creates a workspace.
	 * <span class="attrib">@returns</span> The workspace that was created.
	 * <span class="attrib">@type</span> {Object}
	 */</span>
	<span class="reserved">this</span>.createWorkspace = <span class="reserved">function</span>(){
		var ws = new workspace();
		<span class="reserved">return</span> ws;		
	}
	
	<span class="comment">/**
	 * Returns a workspace by its id.
	 * <span class="attrib">@param</span> {String} id The id of the workspace
	 * <span class="attrib">@return</span> The workspace that has the given id
	 * <span class="attrib">@type</span> {Object} 
	 */</span>
	<span class="reserved">this</span>.get = <span class="reserved">function</span>(id){
		var jsonStr = <span class="literal">""</span>;
		<span class="comment">// Returns a workspace		</span>
		var myRequest = new request();
        myRequest.sendSincRequest(<span class="literal">'GET'</span>, null, <span class="literal">"workspaces/"</span> + id, <span class="reserved">function</span>(response){
            jsonStr = response;
        });
		var json = JSON.parse(jsonStr);
		var ws = new workspace();
		
		<span class="comment">// Fill workspace properties</span>
		ws.id = json[<span class="literal">'id'</span>];
		ws.activeProfile = json[<span class="literal">'current_profile_id'</span>];
		ws.profiles = json[<span class="literal">'profiles'</span>];
		ws.editionAreas = json[<span class="literal">'edition_areas'</span>];
		ws.instructionBoxes = json[<span class="literal">'instruction_boxes'</span>];
		ws.propertyBoxes = json[<span class="literal">'property_boxes'</span>];
		ws.toolBoxes = json[<span class="literal">'tool_boxes'</span>];
		
		<span class="reserved">return</span> ws;
	}
	
	<span class="comment">/**
	 * Returns all existing workspaces.
	 * <span class="attrib">@return</span> An object containing all the workspaces.
	 * <span class="attrib">@type</span> {Object}
	 */</span>
	<span class="reserved">this</span>.all = <span class="reserved">function</span>(){
		var jsonStr = <span class="literal">""</span>;
		<span class="comment">// Returns all workspaces		</span>
		var myRequest = new request();
        myRequest.sendSincRequest(<span class="literal">'GET'</span>, null, <span class="literal">"workspaces"</span>, <span class="reserved">function</span>(response){
            jsonStr = response;
        });
		<span class="reserved">return</span> JSON.parse(jsonStr);
	}
	
	<span class="comment">/**
	 * Removes a workspace by its id.
	 * <span class="attrib">@param</span> {String} id The id of the workspace to remove
	 */</span>
	<span class="reserved">this</span>.remove = <span class="reserved">function</span>(id){
		<span class="comment">// Removes a workspace by id</span>
		var myRequest = new request();
		var params = [];
		params[<span class="literal">'_method'</span>] = <span class="literal">'DELETE'</span>;
        myRequest.sendSincRequest(<span class="literal">'POST'</span>, params, <span class="literal">"workspaces/"</span> + id, <span class="reserved">function</span>(response){});
	}
	
	<span class="comment">/**
	 * Loads an existing worspace by a given id
	 * <span class="attrib">@param</span> {String} id The id of the workspace to load
	 * <span class="attrib">@return</span> The workspace that was loaded
	 * <span class="attrib">@type</span> {Object}
	 */</span>
	<span class="reserved">this</span>.loadWorkspace = <span class="reserved">function</span>(id){
		var wsJSON = <span class="reserved">this</span>.get(id);
		var ws = <span class="reserved">this</span>.createWorkspace();
		
		<span class="comment">// Loading Toolboxes</span>
		var toolboxJSON = null;
		var toolbox = null;
		<span class="reserved">for</span> (var i = 0; i &lt; wsJSON.toolBoxes.length; i++) {
			toolboxJSON = wsJSON.toolBoxes[i]; 
			toolbox = ws.createToolBox(toolboxJSON.id, {
				left: toolboxJSON.left,
				top: toolboxJSON.top,
				width: toolboxJSON.width,
				height: toolboxJSON.height,
				parent: toolboxJSON.parent,
				title: toolboxJSON.title,
				cssPath: toolboxJSON.css_path
			});
			
			<span class="reserved">if</span> (wsJSON.activeProfile) {
				ws.setActiveProfile(wsJSON.activeProfile, toolbox.id, {					
					<span class="comment">// TODO: after creating tool object, remove this hard-coded thing, and complete with each tool properties</span>
					propertyBox: <span class="literal">'propertyBox'</span>,
					instructionBox: <span class="literal">'instructionBox'</span>
				});
			}
		}
		
		<span class="comment">// Loading Property Boxes</span>
		var propertyBoxJSON = null;
		<span class="reserved">for</span> (var i = 0; i &lt; wsJSON.propertyBoxes.length; i++) {
			propertyBoxJSON =  wsJSON.propertyBoxes[i];
			ws.createPropertyBox(propertyBoxJSON.id, {
				left: propertyBoxJSON.left,
				top: propertyBoxJSON.top,
				width: propertyBoxJSON.width,
				height: propertyBoxJSON.height,
				parent: propertyBoxJSON.parent,
				title: propertyBoxJSON.title,
				cssPath: propertyBoxJSON.css_path
			});
		}
		
		<span class="comment">// Loading instruction boxes</span>
		var instructionBoxJSON = null;
		<span class="reserved">for</span> (var i = 0; i &lt; wsJSON.instructionBoxes.length; i++) {
			instructionBoxJSON = wsJSON.instructionBoxes[i]; 
			ws.createInstructionBox(instructionBoxJSON.id, {
				left: instructionBoxJSON.left,
				top: instructionBoxJSON.top,
				width: instructionBoxJSON.width,
				height: instructionBoxJSON.height,
				parent: instructionBoxJSON.parent,
				title: instructionBoxJSON.title,
				cssPath: instructionBoxJSON.css_path
			});
		}
	    
		<span class="comment">// Loading edition areas</span>
		var editionAreaJSON = null;
		<span class="reserved">for</span> (var i = 0; i &lt; wsJSON.editionAreas.length; i++) {
			editionAreaJSON = wsJSON.editionAreas[i]; 
			ws.createEditionArea(editionAreaJSON.id, {
				left: editionAreaJSON.left,
				top: editionAreaJSON.top,
				width: editionAreaJSON.width,
				height: editionAreaJSON.height,
				parent: editionAreaJSON.parent,
				title: editionAreaJSON.title,
				cssPath: editionAreaJSON.css_path
			});
		}
		
		<span class="reserved">return</span> ws;
	}
}
</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Mon Feb 21 18:12:28 2011</div>
</body>
</html>
